package Email.auto.checker;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ClickButtonOpenBrowser implements ActionListener {

	private Notification notification;

	public ClickButtonOpenBrowser(Notification nT) {
		notification = nT;
	}

	@Override
	public void actionPerformed(ActionEvent e) {

		if (!java.awt.Desktop.isDesktopSupported()) {

			System.err.println("Desktop is not supported (fatal)");
			System.exit(1);
		}

		java.awt.Desktop desktop = java.awt.Desktop.getDesktop();

		if (!desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {

			System.err
					.println("Desktop doesn't support the browse action (fatal)");
			System.exit(1);
		}

		try {

			java.net.URI uri = new java.net.URI("http://mail.google.com");
			desktop.browse(uri);
		} catch (Exception e1) {

			System.err.println(e1.getMessage());
		}finally{
			notification.dispose();
		}

	}

}

